package com.example.springaidemo.model;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class ChatSession {
    private final String id;
    private final List<ChatMessage> messages;
    private final long createdAt;
    private long lastActiveAt;

    public ChatSession() {
        this.id = UUID.randomUUID().toString();
        this.messages = new ArrayList<>();
        this.createdAt = System.currentTimeMillis();
        this.lastActiveAt = System.currentTimeMillis();
    }

    public String getId() {
        return id;
    }

    public List<ChatMessage> getMessages() {
        return new ArrayList<>(messages);
    }

    public void addMessage(ChatMessage message) {
        messages.add(message);
        this.lastActiveAt = System.currentTimeMillis();
    }

    public long getCreatedAt() {
        return createdAt;
    }

    public long getLastActiveAt() {
        return lastActiveAt;
    }
}